import { nanoid } from "nanoid";
import { readonly } from "vue";

/**
 *  侧面面板栏配置项说明
 *
 *  type  类别
 *  name 右侧属性配置栏表头名
 *  dateFormat 日期格式
 *  icon  阿里云图标字体名称
 *  appendSlot  输入组件是否有末尾插槽
 *  appendSlotContent  末尾插槽文本
 *  label  标签名
 *  label1  日期区间标签名
 *  label2  日期区间标签名
 *  label3  日期区间标签名
 *  placeholder 占位文本
 *  label3Placeholder 日期区间时长（小时）占位文本
 *  label3CanEidt 日期区间时长是否允许修改
 *  tip 提示语
 *  defaultValueRequired 是否有默认值

 *  dateValue: { 日期
 *    parentDateValue: null, 父时间
 *    childDateValue: null 子时间
 *  },
 *  childDateValue 子日期值（比如上下午）
 *  dateValue: { 日期区间
 *    beginParentDateValue: "", 开始的父时间
 *    beginChildDateValue: "", 开始的子时间
 *    endParentDateValue: "", 结束的父时间
 *    endChildDateValue: "", 结束的子时间
 *    dateRange: null 开始到结束的时长
 *  }
 *  beginDate 日期区间开始日期
 *  endDate 日期区间结束日期
 *  dateRange 日期区间时长
 *  minValue 最小值
 *  maxValue 最大值
 *  isBold 字体是否加粗
 *  amountFormat: { 金额格式
 *    showCapital 显示大写
 *    showThousand 显示千分分隔符
 *    showDecimals 显示小数位数
 *    decimalsCount 小数位数数量
 *  }
 *  selectOptions: [{ 选择项
 *    label: 'Option1', 选择项标签名
 *    value: 'Option1', 选择项值
 *  }]
 *  multiple 是否多选
 *  rulesConfig: { 表单校验规则
 *    trigger: "change", 触发方式
 *    messageTip: "", 校验提示
 *    rules: [] 校验数组
 *  },
 *  options: { 其他可选的配置项
 *    required: true,
 *    requiredLabel: "必填"
 *    defaultValue  默认值
 *  }
 * 
 * 
 * {
    "id": "1",
    "name": "1",
    "options": {
        "minRows": "11",
        "showWordLimit": "00",
        "maxlength": "---",
        "placeholder": "0000",
        "readonly": "",
        "disabled": "00",
        "required": "",
        "detail": "",
        "rules": ""
    }
}
 */

const config = [
  {
    title: "文本",
    config: [
      {
        type: "single-input",
        name: "单行文本",
        id: nanoid(),
        icon: "Edit",
        options: {
          required: false,
          readonly: false,
          requiredLabel: "必填",
          defaultValue: "",
          //默认显示
          placeholder: "请输入",
          //校验条件
          rulesConfig: {
            trigger: "blur",
            messageTip: "请输入内容",
            rules: [],
          },
        },
      },
      {
        type: "textarea",
        name: "多行文本",
        id: nanoid(),
        icon: "icon-duohangwenben",
        options: {
          placeholder: "请输入",
          required: false,
          readonly: false,
          requiredLabel: "必填",
          defaultValue: "",
          rulesConfig: {
            trigger: "blur",
            messageTip: "请输入内容",
            rules: [],
          },
        },
      },
      {
        type: "explain",
        name: "说明",
        id: nanoid(),
        icon: "icon-danxingwenben",
        options: {
          defaultValue: "说明",
        },
      },
    ],
  },
  {
    title: "数值",
    config: [
      {
        type: "number",
        name: "数字",
        id: nanoid(),
        icon: "icon-shuzi",
        options: {
          required: false,
          readonly: false,
          requiredLabel: "必填",
          defaultValue: "",
          placeholder: "请输入",
          tip: "身份证、银行卡等超过 15 位数的情况，请使用文本控件",
          minValue: null,
          maxValue: null,
          rulesConfig: {
            trigger: "blur",
            messageTip: "请输入数值",
            rules: [],
          },
        },
      },
      {
        type: "amount",
        name: "金额",
        id: nanoid(),
        icon: "icon-chongzhi",
        options: {
          required: false,
          requiredLabel: "必填",
          defaultValue: "",
          readonly: false,
          rulesConfig: {
            trigger: "blur",
            messageTip: "请输入数值",
            rules: [],
          },
          appendSlot: true,
          appendSlotContent: "CNY-人民币元",
          placeholder: "请输入",
          minValue: null,
          maxValue: null,
          amountFormat: {
            showCapital: false,
            showThousand: true,
            showDecimals: true,
            decimalsCount: 2,
          },
        },
      },
    ],
  },
  {
    title: "选项",
    config: [
      {
        type: "single-select",
        name: "单选",
        id: nanoid(),
        icon: "icon-xuanzekuanghou",
        options: {
          required: false,
          requiredLabel: "必填",
          defaultValue: null,
          placeholder: "请选择",
          defaultValueRequired: false,
          multiple: false,
          selectOptions: [
            {
              label: "默认值",
              value: "默认值",
            },
          ],
          rulesConfig: {
            trigger: "change",
            messageTip: "请至少选择一项",
            rules: [],
          },
        },
      },
      {
        type: "multiple-select",
        name: "多选",
        id: nanoid(),
        icon: "icon-duoxuananniu",
        options: {
          multiple: true,
          required: false,
          requiredLabel: "必填",
          defaultValue: null,
          placeholder: "请选择",
          defaultValueRequired: false,
          layout:"垂直布局",
          selectOptions: [
            {
              label: "默认值",
              value: "默认值",
            },
          ],
          rulesConfig: {
            trigger: "change",
            messageTip: "请至少选择一项",
            rules: [],
          },
        },
      },
    ],
  },
  {
    title: "日期",
    config: [
      {
        type: "date",
        name: "日期",
        id: nanoid(),
        icon: "icon-riqi",
        options: {
          dateFormat: "YYYY-MM-DD",
          required: false,
          requiredLabel: "必填",
          placeholder: "请选择",
          dateValue: {
            parentDateValue: "",
            childDateValue: "",
          },
          rulesConfig: {
            trigger: "blur",
            messageTip: "请选择日期",
            rules: [],
          },
        },
      },
      {
        type: "date-range",
        name: "日期区间",
        id: nanoid(),
        icon: "icon-24gl-calendar",
        options: {
          dateFormat: "YYYY-MM-DD",
          required: false,
          requiredLabel: "必填",
          label1: "开始时间",
          label2: "结束时间",
          label3: "时长 (天)",
          placeholder: "请选择",
          label3Placeholder: "自动计算",
          label3CanEidt: true,
          dateValue: {
            beginParentDateValue: "",
            beginChildDateValue: "",
            endParentDateValue: "",
            endChildDateValue: "",
            dateRange: "",
          },
          selectOptions: [
            {
              label: "上午",
              value: "am",
            },
            {
              label: "下午",
              value: "pm",
            },
          ],
          rulesConfig: {
            trigger: "blur",
            messageTip: "请选择时间",
            rules: [],
          },
        },
      },
      {
        type: "time",
        name: "时间",
        id: nanoid(),
        icon: "icon-riqi",
        options: {
          required: false,
          requiredLabel: "必填",
          dateFormat: "hh:mm:ss",
          placeholder: "请选择",
          dateValue: {
            parentDateValue: "",
            childDateValue: "",
          },
          rulesConfig: {
            trigger: "blur",
            messageTip: "请选择日期",
            rules: [],
          },
        },
      },
      {
        type: "time-range",
        name: "时间区间",
        id: nanoid(),
        icon: "icon-riqi",
        options: {
          required: false,
          requiredLabel: "必填",
          dateFormat: "hh:mm:ss",
          placeholder: "请选择",
          dateValue: {
            parentDateValue: "",
            childDateValue: "",
          },
          rulesConfig: {
            trigger: "blur",
            messageTip: "请选择日期",
            rules: [],
          },
        },
      },
    ],
  },
  {
    title: "其他",
    config: [
      {
        type: "upload-picture",
        name: "图片",
        id: nanoid(),
        icon: "icon-tupian",
        options: {
          required: false,
          requiredLabel: "必填",
          defaultValue: [],
          rulesConfig: {
            trigger: "change",
            messageTip: "请上传文件",
            rules: [],
          },
        },
      },
      {
        type: "upload-file",
        name: "附件",
        id: nanoid(),
        icon: "icon-fujian",
        options: {
          required: false,
          requiredLabel: "必填",
          defaultValue: [],
          rulesConfig: {
            trigger: "change",
            messageTip: "请上传文件",
            rules: [],
          },
        },
      },
      {
        type: "section",
        name: "部门",
        id: nanoid(),
        icon: "icon-bumen",
        options: {
          required: false,
          requiredLabel: "必填",
          defaultValue: [],
          radioValue: 0,
          radioOptions: [
            { value: 0, label: "可选一个部门" },
            { value: 1, label: "可选多个部门" },
          ],
          rulesConfig: {
            trigger: "change",
            messageTip: "请选择部门",
            rules: [],
          },
        },
      },
    ],
  },
  {
    title: "页面布局",
    config: [
      {
        type: "desc",
        name: "描述文本",
        id: nanoid(),
        icon: "icon-danxingwenben",
        options: {
          defaultValue: 14, // 字体大小
          minValue: 10,
          maxValue: 30,
          isBold: false,
        },
      },
      {
        type: "divider",
        name: "分割线",
        id: nanoid(),
        icon: "icon-danxingwenben",
        options: {}
      },
      {
        type: "layout",
        name: "分栏",
        id: nanoid(),
        icon: "icon-danxingwenben",
        options: {
          required: false,
          requiredLabel: "必填",
          defaultValue: 14, // 字体大小
          minValue: 10,
          maxValue: 30,
          isBold: false,
        },
        items: [],
      },
      {
        type: "table",
        name: "表格",
        id: nanoid(),
        icon: "icon-danxingwenben",
        options: {
          required: false,
          requiredLabel: "必填",
          defaultValue: 14, // 字体大小
          minValue: 10,
          maxValue: 30,
          isBold: false,
        },
        columns: [],
      },
    ],
  },
];

export default config;
